import axios from 'axios';

const AUTH_ENDPOINT = 'https://store.deepin.org/oauth2/token';

export const authenticate = async (clientId, secret) => {
  try {
    const response = await axios.post(AUTH_ENDPOINT, {
      grant_type: 'client_credentials',
      client_id: clientId,
      client_secret: secret
    });
    return response.data.access_token;
  } catch (error) {
    throw new Error(`认证失败: ${error.response.data.error}`);
  }
};